package com.spyx.home.service.impl;

import com.atyx.spyx.model.product.Category;
import com.atyx.spyx.model.product.SkuInfo;
import com.atyx.spyx.model.search.SkuEs;
import com.atyx.spyx.vo.user.LeaderAddressVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spyx.home.service.HomeService;
import com.spyx.product.ProductClient;
import com.spyx.search.SkuFeignClient;
import com.spyx.user.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class HomeServiceImpl  implements HomeService {

    @Autowired
    private UserFeignClient userFeignClient;

    @Autowired
    private ProductClient productClient;

    @Autowired
    private SkuFeignClient skuFeignClient;

    @Override
    public Map getHomeData(Long userId) {
        //1.获取提货点信息
        LeaderAddressVo leaderAddressVo = userFeignClient.getLeaderAddressVoById(userId);
        //2.获取新人专享列表
        List<SkuInfo> skuinfoList = productClient.getNewPersonSkuinfoList();
        //3.获取分类
        List<Category> categoryList = productClient.getCategoryList();
        //4.获取热销好货-从es中获取
        List<SkuEs> hotSkuInfoList = skuFeignClient.getHotSkuInfoList();
        //5.封装数据返回
        Map map=new HashMap();
        map.put("leaderAddressVo",leaderAddressVo);
        map.put("categoryList",categoryList);
        map.put("newPersonSkuInfoList",skuinfoList);
        map.put("hotSkuList",hotSkuInfoList);

        return map;
    }
}
